home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / php / pear / PEAR / Info.php < prev    next >
PHP Script  |  2004-03-24  |  16KB  |  399 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2002 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Davey Shafik <davey@pixelated-dreams.com>                   |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Info.php,v 1.18 2003/12/23 04:46:55 davey Exp $
  20.  
  21. require_once 'PEAR/Remote.php';
  22. require_once 'PEAR/Registry.php';
  23.  
  24. /**
  25.  * @desc PEAR_Info generate phpinfo() style PEAR information
  26.  */
  27.  
  28. class PEAR_Info
  29. {
  30.  
  31.     /**
  32.      * @desc PEAR_Info Constructor
  33.      * @param pear_dir string[optional]
  34.      * @return bool
  35.      * @access public
  36.      */
  37.  
  38.     function PEAR_Info($pear_dir = FALSE, $pear_user_config = FALSE)
  39.     {
  40.         if($pear_user_config === FALSE) {
  41.             $this->config = new PEAR_Config();
  42.         } else {
  43.            $this->config = new PEAR_Config($pear_user_config);
  44.         }
  45.         if ($pear_dir != FALSE) {
  46.             $this->config->set('php_dir',$pear_dir);
  47.         }
  48.         if (defined('PEAR_INFO_PROXY')) {
  49.             $this->config->set('http_proxy',PEAR_INFO_PROXY);
  50.         }
  51.         $this->r = new PEAR_Remote($this->config);
  52.         $this->reg = new PEAR_Registry($this->config->get('php_dir'));
  53.         // get PEARs packageInfo to show version number at the top of the HTML
  54.         $pear = $this->reg->packageInfo("PEAR");
  55.         $this->list_options = false;
  56.         if ($this->config->get('preferred_state') == 'stable') {
  57.             $this->list_options = true;
  58.         }
  59.         ob_start();
  60.         ?>
  61. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  62. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  63.     <head>
  64.         <title>PEAR :: PEAR_Info()</title>
  65.         <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  66.         <style type="text/css">
  67.             body {background-color: #ffffff; color: #000000; white-space: normal;}
  68.             body, td, th, h1, h2 {font-family: sans-serif;}
  69.             a:link {color: #006600; text-decoration: none;}
  70.             a:visited { color: #003300; text-decoration: none;}
  71.             a:hover {text-decoration: underline;}
  72.             table {border-collapse: collapse; width: 600px; max-width: 600px; margin-left: auto; margin-right: auto; border: 0px; padding: 0px;}
  73.             td, th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;}
  74.             h1 {font-size: 150%; text-align: center;}
  75.             h2 {font-size: 125%; text-align: center;}
  76.             .p {text-align: left;}
  77.             .e {background-color: #006600; font-weight: bold; color: #FFFFFF; width: 100px;}
  78.             .e a:link { color: #FFFFFF; }
  79.             .e a:visited { color: #FFFFFF; }
  80.             .h {background-color: #339900; font-weight: bold;}
  81.             .v {background-color: #D9D9D9;}
  82.             img {float: right; border: 0px;}
  83.         </style>
  84.     </head>
  85.     <body>
  86.         <table>
  87.             <tr class="h">
  88.                 <td>
  89.                     <a href="http://pear.php.net/"><img src="<?php echo $_SERVER['PHP_SELF'];?>?pear_image=true" alt="PEAR Logo" /></a><h1 class="p">PEAR <?php echo $pear['version']; ?></h1>
  90.                 </td>
  91.             </tr>
  92.         </table>
  93.     <?php
  94.             if (!isset($_GET['credits'])) {
  95.                 echo '<h1><a href="' .$_SERVER['PHP_SELF']. '?credits=true">PEAR Credits</a></h1>';
  96.                 // Get packageInfo and Show the HTML for the Packages
  97.                 $this->getConfig();
  98.                 echo '<br />';
  99.                 $this->getPackages();
  100.  
  101.             } else {
  102.                 $this->getCredits();
  103.             }
  104.         ?>
  105.     </body>
  106. </html>
  107.         <?php
  108.         $this->info = ob_get_contents();
  109.         ob_end_clean();
  110.         /* With later versions of this where we properly implement the CLI such and stuff
  111.         this will return the actual status of whether or not creating the PEAR_Info object worked */
  112.         return true;
  113.     }
  114.  
  115.     /**
  116.      * @desc Set PEAR http_proxy for remote calls
  117.      * @param proxy string
  118.      * @return bool
  119.      * @access public
  120.      */
  121.  
  122.     function setProxy($proxy)
  123.     {
  124.         define('PEAR_INFO_PROXY',$proxy);
  125.         return true;
  126.     }
  127.  
  128.     /**
  129.      * @desc Retrieve and format PEAR Packages info
  130.      * @return void
  131.      * @access private
  132.      */
  133.  
  134.     function getPackages()
  135.     {
  136.         $latest = @$this->r->call('package.listLatestReleases');
  137.         $available = $this->reg->listPackages();
  138.         if (PEAR::isError($available)) {
  139.             echo '<h1 style="font-size: 12px;">An Error occured fetching the package list. Please try again.</h1>';
  140.             return FALSE;
  141.         }
  142.         if (!is_array($available)) {
  143.             echo '<h1 style="font-size: 12px;">The package list could not be fetched from the remote server. Please try again.</h1>';
  144.             return FALSE;
  145.         }
  146.         natcasesort($available);
  147.         if ((PEAR::isError($latest)) || (!is_array($latest))) {
  148.             $latest = FALSE;
  149.         }
  150.         $packages = '';
  151.         foreach ($available as $name) {
  152.             $installed = $this->reg->packageInfo($name);
  153.                 if (strlen($installed['package']) > 1) {
  154.                 if (!isset($old_index)) {
  155.                     $old_index = '';
  156.                 }
  157.                 $current_index = $name{0};
  158.                 if (strtolower($current_index) != strtolower($old_index)) {
  159.                     $packages .= '<a name="' .$current_index. '"></a>';
  160.                     $old_index = $current_index;
  161.                     $this->index[] = $current_index;
  162.                 }
  163.                 $packages .= '
  164.         <h2><a name="pkg_' .trim($installed['package']). '">' .trim($installed['package']). '</a></h2>
  165.         <table>
  166.             <tr class="v">
  167.                 <td class="e">
  168.                     Summary
  169.                 </td>
  170.                 <td>
  171.                     ' .nl2br(htmlentities(trim($installed['summary']))). '
  172.                 </td>
  173.             </tr>
  174.             <tr class="v">
  175.                 <td class="e">
  176.                     Version
  177.                 </td>
  178.                 <td>
  179.                     ' .trim($installed['version']). '
  180.                 </td>
  181.             </tr>
  182.             <tr class="v">
  183.                 <td class="e">
  184.                     Description
  185.                 </td>
  186.                 <td>
  187.                     ' .nl2br(htmlentities(trim($installed['description']))). '
  188.                 </td>
  189.             </tr>
  190.             <tr class="v">
  191.                 <td class="e">
  192.                     State
  193.                 </td>
  194.                 <td>
  195.                     ' .trim($installed['release_state']). '
  196.                 </td>
  197.             </tr>
  198.             <tr class="v">
  199.                 <td class="e">
  200.                     Information
  201.                 </td>
  202.                 <td>
  203.                     <a href="http://pear.php.net/' .trim(strtolower($installed['package'])). '">http://pear.php.net/' .trim(strtolower($installed['package'])). '</a>
  204.                 </td>
  205.             </tr>';
  206.             if ($latest != FALSE) {
  207.                 if (isset($latest[$installed['package']])) {
  208.                     if (version_compare($latest[$installed['package']]['version'],$installed['version'],'>')) {
  209.                         $packages .= '<tr class="v">
  210.                         <td class="e">
  211.                             Latest Version
  212.                         </td>
  213.                         <td>
  214.                             <a href="http://pear.php.net/get/' .trim($installed['package']). '">' .$latest[$installed['package']]['version'] . '</a>
  215.                             ('. $latest[$installed['package']]['state']. ')
  216.                         </td>
  217.                         </tr>';
  218.                     }
  219.                 }
  220.             }
  221.         $packages .= '          <tr>
  222.                 <td colspan="2" class="v"><a href="#top">Top</a></td>
  223.             </tr>
  224.         </table>';
  225.             }
  226.         }
  227.         ?>
  228.         <h2><a name="top">PEAR Packages</a></h2>
  229.         <table style="padding: 3px;">
  230.             <tr>
  231.                 <td class="e">
  232.                     Index
  233.                 </td>
  234.             </tr>
  235.             <tr>
  236.                 <td class ="v" style="text-align: center">
  237.         <?php
  238.         foreach ($this->index as $i) {
  239.             ?>
  240.             | <a href="#<?php echo $i; ?>"><?php echo strtoupper($i); ?></a>
  241.             <?php
  242.         }
  243.         ?>|
  244.                 </td>
  245.             </tr>
  246.         </table>
  247.         <br />
  248.         <?php
  249.         echo $packages;
  250.     }
  251.  
  252.     /**
  253.      * @desc Retrieves and formats the PEAR Config data
  254.      * @return void
  255.      * @access private
  256.      */
  257.  
  258.     function getConfig()
  259.     {
  260.         $keys = $this->config->getKeys();
  261.         sort($keys);
  262.         ?>
  263.         <h2>PEAR Config</h2>
  264.         <table>
  265.         <?php
  266.         foreach ($keys as $key) {
  267.             if (($key != 'password') && ($key != 'username') && ($key != 'sig_keyid') && ($key != 'http_proxy')) {
  268.                 ?>
  269.                 <tr class="v">
  270.                     <td class="e"><?php echo $key; ?></td>
  271.                     <td><?php echo $this->config->get($key); ?></td>
  272.                 </tr>
  273.                 <?php
  274.             }
  275.         }
  276.         ?>
  277.         </table>
  278.         <?php
  279.     }
  280.  
  281.     /**
  282.      * @desc Retrieves and formats the PEAR Credits
  283.      * @return void
  284.      * @access private
  285.      */
  286.  
  287.     function getCredits()
  288.     {
  289.         ?>
  290.         <h1>PEAR Credits</h1>
  291.         <table>
  292.             <tr class="h">
  293.                 <td>
  294.                     PEAR Website Team
  295.                 </td>
  296.             </tr>
  297.             <tr class="v">
  298.                 <td>
  299.                     <a href="http://pear.php.net/account-info.php?handle=ssb">Stig Bakken</a>,
  300.                     <a href="http://pear.php.net/account-info.php?handle=cox">Thomas V.V.Cox</a>,
  301.                     <a href="http://pear.php.net/account-info.php?handle=mj">Martin Jansen</a>,
  302.                     <a href="http://pear.php.net/account-info.php?handle=cmv">Colin Viebrock</a>,
  303.                     <a href="http://pear.php.net/account-info.php?handle=richard">Richard Heyes</a>
  304.                 </td>
  305.             </tr>
  306.         </table>
  307.         <br />
  308.         <table>
  309.             <tr class="h">
  310.                 <td>
  311.                     PEAR documentation team
  312.                 </td>
  313.             </tr>
  314.             <tr class="v">
  315.                 <td>
  316.                     <a href="http://pear.php.net/account-info.php?handle=cox">Thomas V.V.Cox</a>,
  317.                     <a href="http://pear.php.net/account-info.php?handle=mj">Martin Jansen</a>,
  318.                     <a href="http://pear.php.net/account-info.php?handle=alexmerz">Alexander Merz</a>
  319.                 </td>
  320.             </tr>
  321.         </table>
  322.         <?php
  323.         $available = $this->reg->listPackages();
  324.  
  325.         if (PEAR::isError($available)) {
  326.             echo '<h1 style="font-size: 12px;">An Error occured fetching the credits from the remote server. Please try again.</h1>';
  327.             return FALSE;
  328.         }
  329.         if (!is_array($available)) {
  330.             echo '<h1 style="font-size: 12px;">The credits could not be fetched from the remote server. Please try again.</h1>';
  331.             return FALSE;
  332.         }
  333.         echo '<br /><table border="0" cellpadding="3" width="600">';
  334.         echo '<tr class="h"><td>Package</td><td>Maintainers</td></tr>';
  335.         foreach ($available as $name) {
  336.             $installed = $this->reg->packageInfo($name);
  337.             if (strlen($installed['package']) > 1) {
  338.                 ?>
  339.                 <tr>
  340.                     <td class="e">
  341.                         <a href="http://pear.php.net/<?php echo trim(strtolower($installed['package'])); ?>"><?php echo trim($installed['package']); ?></a>
  342.  
  343.                     </td>
  344.                     <td class="v">
  345.                         <?php
  346.                         $maintainers = array();
  347.                         foreach ($installed['maintainers'] as $i) {
  348.                             $maintainers[] = '<a href="http://pear.php.net/account-info.php?handle=' .$i['handle']. '">' .htmlentities($i['name']). '</a>' .' (' .$i['role']. ')';
  349.                         }
  350.                         echo implode(', ',$maintainers);
  351.                         ?>
  352.                     </td>
  353.                 </tr>
  354.                 <?php
  355.             }
  356.         }
  357.         echo '</table>';
  358.     }
  359.  
  360.     /**
  361.      * @desc outputs the PEAR logo
  362.      * @return void
  363.      * @access public
  364.      */
  365.  
  366.     function pearImage() {
  367.         $pear_image = 'R0lGODlhaAAyAMT/AMDAwP3+/TWaAvD47Pj89vz++zebBDmcBj6fDEekFluvKmu3PvX68ujz4XvBS8LgrNXqxeHw1ZnPaa/dgvv9+cLqj8LmltD2msnuls';
  368.         $pear_image .= '3xmszwmf7+/f///wAAAAAAAAAAACH5BAEAAAAALAAAAABoADIAQAX/ICCOZGmeaKqubOtWWjwJphLLgH1XUu//C1Jisfj9YLEKQnSY3GaixWQqQTkYHM4';
  369.         $pear_image .= 'AMulNLJFC9pEwIW/odKU8cqTfsWoTTtcomU4ZjbR4ZP+AgYKCG0EiZ1AuiossEhwEXRMEg5SVWQ6MmZqKWD0QlqCUEHubpaYlExwRPRZioZZVp7KzKQoS';
  370.         $pear_image .= 'DxANDLsNXA5simd2FcQYb4YAc2jEU80TmAAIztPCMcjKdg4OEsZJmwIWWQPQI4ikIwtoVQnddgrv8PFlCWgYCwkI+fp5dkvJ/IlUKMCy6tYrDhNIIKLFE';
  371.         $pear_image .= 'AWCTxse+ABD4SClWA0zovAjcUJFi6EwahxZwoGqHhFA/4IqoICkyxQSKkbo0gDkuBXV4FRAJkRCnTgi2P28IcEfk5xpWppykFJVuScmEvDTEETAVJ6bEp';
  372.         $pear_image .= 'ypcADPkz3pvKVAICHChkC7siQ08zVqu4Q6hgIFEFZuEn/KMgRUkaBmAQs+cEHgIiHVH5EAFpIgW4+NT6LnaqhDwe/Ov7YOmWZp4MkiAWBIl0kAVsJWuzc';
  373.         $pear_image .= 'YpdiNgddc0E8cKBAu/FElBwagMb88ZZKDRAkWJtkWhHh3wwUbKHQJN3wQAaXGR2LpArv5oFHRR34C7Mf6oLXZNfqBgNI7oOLhj1f8PaGpygHQ0xtP8MDV';
  374.         $pear_image .= 'KwYTSKcgxr9/hS6/pCCAAg5M4B9/sWh1YP9/XSgQWRML/idBfKUc4IBET9lFjggKhDYZAELZJYEBI2BDB3ouNBEABwE8gAwiCcSYgAKqPdEVAG7scM8BP';
  375.         $pear_image .= 'PZ4AIlM+OgjAgpMhRE24OVoBwsIFEGFA7ZkQQBWienWxmRa7XDjKZXhBdAeSmKQwgLuUVLICa6VEKIGcK2mQWoVZHCBXJblJUFkY06yAXlGsPIHBEYdYi';
  376.         $pear_image .= 'WHb+WQBgaIJqqoHFNpgMGB7dT5ZQuG/WbBAIAUEEFNfwxAWpokTIXJAWdgoJ9kRFG2g5eDRpXSBpEIF0oEQFaZhDbaSFANRgqcJoEDRARLREtxOQpsPO9';
  377.         $pear_image .= '06ZUeJgjQB6dZUPBAdwcF8KLXXRVQaKFcsRRLJ6vMiiCNKxRE8ECZKgUA3Va4arOAAqdGRWO7uMZH5AL05gvsjQbg6y4NCjQ1kw8TVGcbdoKGKx8j3bGH';
  378.         $pear_image .= '7nARBArqwi0gkFJBrZiXBQRbHoIgnhSjcEBKfD7c3HMhz+JIQSY3t8GGKW+SUhfUajxGzKd0IoHBNkNQK86ZYEqdzYA8AHQpqXRUm80oHs1CAgMoBxzRq';
  379.         $pear_image .= 'vzs9CIKECC1JBp7enUpfXHApwVYNAfo16c4IrYPLVdSAJVob7IAtCBFQGHcs/RRdiUDPHA33oADEAIAOw==';
  380.         header('content-type: image/gif');
  381.         echo base64_decode($pear_image);
  382.     }
  383.  
  384.     /**
  385.      * @desc Shows PEAR_Info output
  386.      * @return void
  387.      * @access public
  388.      */
  389.  
  390.     function show() {
  391.         echo $this->info;
  392.     }
  393. }
  394.  
  395. if (isset($_GET['pear_image'])) {
  396.     PEAR_Info::pearImage();
  397.     exit;
  398. }
  399. ?>